<nz-breadcrumb class="breadcrumb">
  <nz-breadcrumb-item>
    <a routerLink="/Home">首页</a>
  </nz-breadcrumb-item>
  <nz-breadcrumb-item>报修信息列表</nz-breadcrumb-item>
</nz-breadcrumb>
<form nz-form class="search-form" [formGroup]="searchForm" (keydown.enter)="$event.preventDefault();onSearch()" nzLayout="inline">
  <nz-form-item>
    <nz-form-label nzFor="buildingName">楼栋名称</nz-form-label>
    <nz-form-control>
      <nz-input-group nzSearch [nzAddOnAfter]="buildingNameSuffixIconButton">
        <input nz-input formControlName="buildingName" placeholder="请选择楼栋名称" readonly />
      </nz-input-group>
      <ng-template #buildingNameSuffixIconButton>
        <button nz-button nzType="primary" nzSearch (click)="findBuilding()"><nz-icon nzType="search" /></button>
      </ng-template>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label nzFor="roomNumber">单元房号</nz-form-label>
    <nz-form-control>
      <nz-input-group nzSearch [nzAddOnAfter]="roomNumberSuffixIconButton">
        <input nz-input formControlName="roomNumber" placeholder="请选择单元房号" readonly />
      </nz-input-group>
      <ng-template #roomNumberSuffixIconButton>
        <button nz-button nzType="primary" nzSearch (click)="findRoom()"><nz-icon nzType="search" /></button>
      </ng-template>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label nzFor="status">状态</nz-form-label>
    <nz-form-control>
      <nz-select formControlName="status" class="custom-select-width">
        <nz-option nzLabel="待处理" [nzValue]="10"></nz-option>
        <nz-option nzLabel="处理中" [nzValue]="20"></nz-option>
        <nz-option nzLabel="已完成" [nzValue]="30"></nz-option>
      </nz-select>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label nzFor="staffName">维修保养人员</nz-form-label>
    <nz-form-control>
      <nz-input-group nzSearch [nzAddOnAfter]="staffNameSuffixIconButton">
        <input nz-input formControlName="staffName" placeholder="请选择维修保养人员" readonly />
      </nz-input-group>
      <ng-template #staffNameSuffixIconButton>
        <button nz-button nzType="primary" nzSearch (click)="findStaff()"><nz-icon nzType="search" /></button>
      </ng-template>
    </nz-form-control>
  </nz-form-item>
  <button nz-button type="button" nzType="primary" [nzLoading]="searchLoading" (click)="onSearch()">查询</button>
  <button nz-button type="button" class="margin-button" (click)="onReset()">重置</button>
  <button nz-button type="button" class="margin-button" nzType="primary" (click)="onAdd()">新增</button>
  <button nz-button type="button" class="margin-button" nzType="primary" [nzLoading]="searchLoading" (click)="onExport()">导出</button>
</form>
<nz-table #basicTable [nzData]="listOfData" [nzTotal]="total" [nzLoading]="searchLoading" nzSize="small">
  <thead>
    <tr>
      <th>楼栋名称</th>
      <th>单元房号</th>
      <th>问题描述</th>
      <th>报修时间</th>
      <th>状态</th>
      <th>维修保养人员</th>
      <th>备注</th>
      <th>完成时间</th>
      <th nzWidth="250px">操作</th>
    </tr>
  </thead>
  <tbody>
    <tr *ngFor="let data of basicTable.data">
      <td>{{data.buildingName}}</td>
      <td>{{data.roomNumber}}</td>
      <td class="ellipsis">{{data.description}}</td>
      <td>{{data.requestTime}}</td>
      <td>
        <ng-container *ngIf="data.status === 10">待处理</ng-container>
        <ng-container *ngIf="data.status === 20">处理中</ng-container>
        <ng-container *ngIf="data.status === 30">已完成</ng-container>
      </td>
      <td>{{data.staffName}}</td>
      <td>{{data.remark}}</td>
      <td>{{data.finishTime}}</td>
      <td>
        <button nz-button type="button" nzType="primary" (click)="editRow(data.id)">编辑</button>
        <button nz-button type="button" nzDanger class="margin-button" (click)="delRow(data.id)">删除</button>
        <button nz-button type="button" class="margin-button" (click)="detailRow(data)">详情</button>
      </td>
    </tr>
  </tbody>
</nz-table>
<building-selector (buildingSelectedEvent)="handleBuildingSelectedEvent($event)"></building-selector>
<room-selector (roomSelectedEvent)="handleRoomSelectedEvent($event)"></room-selector>
<staff-selector (staffSelectedEvent)="handleStaffSelectedEvent($event)"></staff-selector>
<repair-request-add (addedEvent)="onAdded($event)"></repair-request-add>
<repair-request-view></repair-request-view>
